<?php

    /**
     * Tecdoc
     *
     * @package      Core
     * @subpackage   Soap
     *
     * @license      GNU Lesser General Public Licence see LICENCE-LGPL file or http://www.gnu.org/licenses/lgpl.html
     */
	class Core_Soap_Tecdoc extends Core_Soap_Abstract
	{

    ////////////////////////////////////////////////////////////////////////////
	//                                Variables                               //
	////////////////////////////////////////////////////////////////////////////

		/**
		 * URL of the SOAP Sever
		 *
		 * @var string
		 */
		protected $_url = 'http://webservice-cs.tecdoc.net/pegasus-1-3/wsdl/TecdocToCat';

        /**
         * The tecdoc provider for the webservice
         *
         * @var integer
         */
        protected $_provider = 237;

	////////////////////////////////////////////////////////////////////////////
	//                                 Methods                                //
	////////////////////////////////////////////////////////////////////////////

        /**
         * Calls the SOAP server with the requested parameters
         *
         * @param       string      $method
         * @param       array       $params
         * @throws      Core_Exception
         * @return      array
         */
        public function call($method, array $params = array())
        {
            if (!($this->_adapter) instanceof Core_Soap_Adapter_Abstract) {
                throw new Core_Exception('Fatal error: adapter inst\'t an instance of Core_Soap_Adapter_Abstract');
            }

            if (!isset($params['provider'])) {
                $params['provider'] = $this->_provider;
            }

            $this->_adapter->setWsdl($this->_url);
            $result = $this->_adapter->call($method, $params);

            if (isset($result['status']) && $result['status'] != '200') {
                throw new Core_Exception($result['statusText']);
            }

            if (isset($result['data']['array'])) {
                return $result['data']['array'];
            } else {
                return array();
            }
        }
	}
